package com.ruoyi.personnel.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.personnel.vo.IntervieweeInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.personnel.mapper.IntervieweeInfoMapper;
import com.ruoyi.personnel.domain.IntervieweeInfo;
import com.ruoyi.personnel.service.IIntervieweeInfoService;

/**
 * 受访人信息Service业务层处理
 *
 * @author ruoyi
 * @date 2020-03-02
 */
@Service
public class IntervieweeInfoServiceImpl implements IIntervieweeInfoService {
    @Autowired
    private IntervieweeInfoMapper intervieweeInfoMapper;

    /**
     * 查询受访人信息
     *
     * @param id 受访人信息ID
     * @return 受访人信息
     */
    @Override
    public IntervieweeInfo selectIntervieweeInfoById(Long id)
    {
        return intervieweeInfoMapper.selectIntervieweeInfoById(id);
    }

    /**
     * 查询受访人信息列表
     *
     * @param intervieweeInfo 受访人信息
     * @return 受访人信息
     */
    @Override
    public List<IntervieweeInfo> selectIntervieweeInfoList(IntervieweeInfo intervieweeInfo)
    {
        return intervieweeInfoMapper.selectIntervieweeInfoList(intervieweeInfo);
    }

    /**
     * 新增受访人信息
     *
     * @param intervieweeInfo 受访人信息
     * @return 结果
     */
    @Override
    public int insertIntervieweeInfo(IntervieweeInfo intervieweeInfo)
    {
        return intervieweeInfoMapper.insertIntervieweeInfo(intervieweeInfo);
    }

    /**
     * 修改受访人信息
     *
     * @param intervieweeInfo 受访人信息
     * @return 结果
     */
    @Override
    public int updateIntervieweeInfo(IntervieweeInfo intervieweeInfo)
    {
        return intervieweeInfoMapper.updateIntervieweeInfo(intervieweeInfo);
    }

    /**
     * 删除受访人信息对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteIntervieweeInfoByIds(String ids)
    {
        return intervieweeInfoMapper.deleteIntervieweeInfoByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除受访人信息信息
     *
     * @param id 受访人信息ID
     * @return 结果
     */
    @Override
    public int deleteIntervieweeInfoById(Long id)
    {
        return intervieweeInfoMapper.deleteIntervieweeInfoById(id);
    }


    /**
     * 查询受访人姓名
     * @param intervieweeInfoVO 前台传输的数据作为查询的条件
     * @return
     */
    @Override
    public AjaxResult selectIntervieweeListByPhone(IntervieweeInfoVO intervieweeInfoVO) {
            List<IntervieweeInfo> list = intervieweeInfoMapper.selectIntervieweeListByPhone(intervieweeInfoVO.getPhone());
            if (list.size() == 0) {
                return new AjaxResult(AjaxResult.Type.SUCCESS, "电话号码不存在", "");
            }
            IntervieweeInfo intervieweeInfo = (IntervieweeInfo) list.get(0);
            return new AjaxResult(AjaxResult.Type.SUCCESS, "操作成功", intervieweeInfo);
    }
}